CXX := g++
CXXFLAGS := -std=c++17 -Wall -Wextra -I.. -g  

TARGET := test_runner
SRCS := test_runner.cpp ../parser.tab.cpp ../lex.yy.cpp ../ir.cpp \
	../symbol_table.cpp ../reg_alloc.cpp ../live_var.cpp ../cfg.cpp \
	../code_peephole.cpp ../code.cpp ../ir_constOptimizer.cpp \
	../ir_optimizer.cpp ../dead_code_elimination.cpp
OBJS := $(SRCS:.cpp=.o)
GENS := ../parser.tab.hpp ../parser.tab.cpp ../lex.yy.cpp

$(TARGET): ../parser.tab.hpp $(OBJS) 
	$(CXX) $(CXXFLAGS) -o $@ $^
	rm -f $(OBJS)

%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

../parser.tab.hpp ../parser.tab.cpp: ../parser.y
	bison -d -o ../parser.tab.cpp ../parser.y

../lex.yy.cpp: ../parser.tab.hpp ../lexer.l
	flex -o ../lex.yy.cpp ../lexer.l

clean:
	rm -f $(TARGET) $(OBJS) $(GENS)

.PHONY: clean